<include file="Public/min-header"/>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <style>#search-form > .form-group{margin-left: 10px;}</style>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 店铺申请列表</h3>
                </div>
                <div class="panel-body">
                    <div class="navbar navbar-default">
                        <button type="button" class="btn btn-primary pull-right"  onclick="location.href='{:U('Admin/Shop/add_shop_type')}'" data-toggle='tooltip'data-original-title="添加类型">
                            <i class="fa fa-plus"></i> 添加类型
                        </button>
                    </div>
                    <div id="ajax_return">
                        <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <td style="width: 1px;" class="text-center">
                                        </td>
                                        <td class="text-right">
                                            <a href="javascript:sort('goods_id');">ID</a>
                                        </td>
                                        <td class="text-left">
                                            <a href="#">店铺类型名称</a>
                                        </td>
                                        <td class="text-left">
                                            <a href="#">保证金</a>
                                        </td>
                                        <td class="text-left">
                                            <a href="#">排序</a>
                                        </td>
                                        <td class="text-left">
                                            <a href="#">创建时间</a>
                                        </td>
                                        <td class="text-left">
                                            <a href="#">修改时间</a>
                                        </td>
                                        <td class="text-left">
                                            <a href="#">是否显示</a>
                                        </td>
                                        <td class="text-center">操作</td>
                                    </tr>
                                    </thead>
                                    <tbody id="box">
                                    <foreach name='data' item='v'>

                                        <tr>
                                            <td class="text-center">
                                                <!-- <input type="checkbox" name="selected[]" value="6">-->
                                                <input type="hidden" name="shipping_code[]" value="flat.flat">
                                            </td>
                                            <td class="text-right">{$v.id}</td>
                                            <td class="text-left">{$v.shop_type_name}</td>
                                            <td class="text-left">{$v.bond_price}</td>
                                            <td class="text-left">{$v.sort}</td>
                                            <td class="text-left">{$v.create_time}</td>
                                            <td class="text-left">{$v.update_time}</td>
                                            <td class="text-left">
                                                <if condition="$v['is_show'] eq 1">
                                                    显示
                                                    <else />
                                                    不显示
                                                </if>
                                            </td>
                                            <td class="text-center">
                                                <a href="{:U('Shop/update_shop_type',array('id'=>$v['id']))}"data-toggle="tooltip" title="" class="btn btn-info" data-original-title="编辑">编辑</a>
                                                <a class="btn btn-danger" href="javascript:del_fun('{:U('Shop/shop_type_del',array('id'=>$v['id']))}');" data-toggle='tooltip'data-original-title="删除">	<i class="fa fa-trash-o"></i></a>
                                            </td>
                                        </tr>
                                    </foreach>

                                    </tbody>
                                </table>
                            </div>
                            <input type="hidden" name="__hash__" value="00ea0d70ce1e0760a8bf5d90b5e30971_08363ccf4ed4c12cc7ec489900643f53" />
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script>

    $(document).on('click','#jinyong',function(){
        var id=$(this).attr('val');
        update_shop_status(id,0);
    });
    //修改店铺状态
    function update_shop_status(id,shop_status){
        $.ajax({
            url:"/index.php?m=Admin&c=Shop&a=update_shop_status",
            type:"post",
            data:{id:id,shop_status:shop_status},
            dataType:"json",
            success: function(msg) {
                if(msg.result ==400 || msg.result=='400'){
                    alert('禁用失败');
                }else {
                    alert('禁用成功');
                    window.location.href="";
                }
            }
        });
    }

    // 点击排序
    function sort(field)
    {
        $("input[name='orderby1']").val(field);
        var v = $("input[name='orderby2']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='orderby2']").val(v);
        ajax_get_table('search-form2',cur_page);
    }
    $(document).on('click','#shop_name',function() {
        var shop_type=$('#shop_type').val();
        var shop_name=$('#input-shop-name').val();
        shop_list_search(shop_type,shop_name);
    });
    $("#shop_type").change(function(){
        var shop_type=$('#shop_type').val();
        var shop_name=$('#input-shop-name').val();
        shop_list_search(shop_type,shop_name);
    });
    $(document).on('click','.num',function(){
        var p=$(this).data('p');
        $(this).parent('li').siblings().removeClass('active');
        $(this).parent('li').addClass('active');
        var shop_type=$('#shop_type').val();
        var shop_name=$('#input-shop-name').val();
        shop_list_search(shop_type,shop_name,p);
    });

    function shop_list_search(shop_type,shop_name,p){
        $.ajax({
            url:"/index.php?m=Admin&c=Shop&a=shop_list_search",
            type:"post",
            data:{shop_type:shop_type,shop_name:shop_name,p:p},
            dataType:"json",
            success: function(msg) {
                if(msg.result ==400 || msg.result=='400'){
                    $('#box').html('<tr>没有找到你搜索的店铺</tr>');
                }else {
                    var content="";
                    $.each(msg.data.shop_data,function(k,v){
                        content+='<tr>';
                        content+='<td class="text-center">';
                        content+='<input type="hidden" name="shipping_code[]" value="flat.flat">';
                        content+='</td>';
                        content+='<td class="text-right">'+v.id+'</td>';
                        content+='<td class="text-left">'+v.shop_name+'</td>';
                        content+='<td class="text-left"><img width="100px" height="100px" src="'+v.shop_head_img+'" alt=""/></td>';
                        content+='<td class="text-left">'+ v.license_name+'</td>';
                        content+='<td class="text-left">'+v.license_address+'</td>';
                        content+='<td class="text-left"><img width="100px" height="100px" src="'+v.license_img+'" alt=""/></td>';
                        content+='<td class="text-left">'+v.shop_user+'</td>';
                        content+='<td class="text-left">'+v.shop_tel+'</td>';
                        content+='<td class="text-left">'+v.shop_type_name+'</td>';
                        content+='<td class="text-left">'+v.shop_bond+'</td>';
                        content+='<td class="text-center">';
                        content+='审核通过';
                        content+='</td>';
                        content+='<td class="text-center">';
                        content+='<a href="#" id="jinyong" val="'+ v.id+'" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="禁用">禁用</a>';
                        content+='</td>';
                        content+='</tr>';
                    });
                    $('#box').html(content);
                    var str="";
                    str+='<li class="paginate_button"><a class="num" data-p="1" href="javascript:void(0)">首页</a></li>';
                    str+='<li class="paginate_button"><a class="num" href="javascript:void(0)" data-p="'+msg.data.last+'" >上一页</a></li>';
                    str+='<li class="paginate_button"><a class="num" href="javascript:void(0)" data-p='+msg.data.next+' >下一页</a></li>';
                    str+='<li class="paginate_button"><a class="num" href="javascript:void(0)" data-p='+msg.data.total_page+'>尾页</a></li>';
                    str+='<li style="margin-left: 2rem;">当前为第'+msg.data.p+'页</li>';
                    str+='<li style="margin-left: 2rem;">共'+msg.data.total_page+'页</li>';
                    $('.pagination').html(str);

                }

            }
        });
    }

    $(document).on('click','#del',function(){
        var id=$(this).attr('val');
        if(confirm('确定要删除吗?')){
           window.location.href="/index.php?m=Admin&c=Shop&a=shop_type_del/id/"+id;
        }
        return false;
    });

</script>
</body>
</html>